package com.example.theorygame.layer;
/**
 * 介绍界面
 */

import android.view.MotionEvent;

import com.example.theorygame.util.CommouUtils;

import org.cocos2d.nodes.CCSprite;
import org.cocos2d.types.CGPoint;
import org.cocos2d.types.CGRect;

/**
 * 介绍页面
 *
 * @author yangfan
 */
public class FirstLayer extends BaseLayer {
    /**
     * 变量声明
     */
    private CCSprite bj;
    private CCSprite play;
    private CCSprite text;

    public FirstLayer() {
        //白色背景
        bj = CCSprite.sprite("image/bg.png");
        bj.setAnchorPoint(0, 0);
        bj.setPosition(0, 0);
        this.addChild(bj, 0);
        //文字
        text = CCSprite.sprite("image/conclusion/text1.png");
        text.setAnchorPoint(0, 0);
        text.setPosition((winSize.width - 400) / 2, winSize.height - 270);
        this.addChild(text, 1);
        //按钮开始游戏
        play = CCSprite.sprite("image/conclusion/layer1_play.png");
        play.setAnchorPoint(0, 0);
        play.setScale(0.3f);
        play.setPosition((winSize.width - 400) / 4 * 3 + 80, 5);
        this.addChild(play, 1);
        setIsTouchEnabled(true);
    }

    /**
     * 触摸事件
     */
    @Override
    public boolean ccTouchesBegan(MotionEvent event) {
        CGPoint conver = this.convertTouchToNodeSpace(event);
        if (CGRect.containsPoint(play.getBoundingBox(), conver)) {
            CommouUtils.changeLayer(new SecondLayer());
        }


        return true;

    }
}
